package com.seaengine.actor.state
{

	/**
	 * 玩家状态
	 * @author marz
	 *
	 * 玩家自己的状态
	 * 0:死亡；
	 * 1:空闲；
	 * 2:战斗；
	 * 3:回气中（取消）；
	 * 4:武功升级中（取消）；
	 * 5:等待复活（取消）；
	 * 6:PVE战斗（取消）；
	 * 7:PVP战斗（取消）；
	 * 8:战斗等待；
	 * 9:挂机升级；
	 * 10:在线挂机；
	 * 11:跑马车
	 */
	public class PlayerState
	{
		public static const DEATH:int = 0; /**死亡*/
		public static const IDLE:int = 1; /**空闲*/
		public static const FIGHTING:int = 2; /**战斗*/
		public static const CURING:int = 3; /**回气中*/
		public static const IDLE_NONE_CURING:int = 4; /**空闲不回气*/
		public static const FIGHT_REQUESTING:int = 8; /**战斗等待*/
		public static const EXERCISING:int = 9; /**挂经验*/
		public static const TRAINING:int = 10; /**挂潜能*/
		public static const MOVE_TO_MAP:int = 11; /**跑马车*/

		private var _state:int;

		public function set state(value:int):void
		{
			if (value != _state)
				changeState(value);
		}

		public function get state():int
		{
			return _state;
		}

		/**
		 * 状态切换
		 *
		 */
		public function changeState(state:int):void
		{
			switch (_state)
			{
				case PlayerState.DEATH:
					_state = state;
					break;
				case PlayerState.IDLE:
					_state = state;
					break;
				case PlayerState.FIGHTING:
					_state = state;
					break;
				case PlayerState.CURING:
					if (!(state == PlayerState.IDLE || state == PlayerState.CURING)) /**当新状态是idle或curing时，无须停止回气*/
					{
						_state = state;
					}
					break;
				case PlayerState.FIGHT_REQUESTING:
					_state = state;
					break;
				case PlayerState.EXERCISING:
					_state = state;
					break;
				case PlayerState.TRAINING:
					_state = state;
					break;
				case PlayerState.MOVE_TO_MAP:
					_state = state;
					break;
				default:
					_state = state;
					break;
			}
		}

		/**################################*/
		private static var instance:PlayerState;

		public static function getInstance():PlayerState
		{
			if (!instance)
				instance = new PlayerState(new Singleton);
			return instance;
		}

		public function PlayerState(sin:Singleton)
		{
		}
	}
}

class Singleton
{
}